/* FluxamasynthBendingNotes.pde
 * Demonstrates note bending on the Modern Device Fluxamasynth Shield
 * ModernDevice.com
 */

#include <FlexamySynth.h>
#include <PgmChange.h>

FlexamySynth synth;

void setup()
{
  synth.begin();
  synth.GS_Reset();

  synth.programChange( 0, GM_Pad_Choir );
  synth.setBendRange( 0, 3 );  // three semitones

  synth.noteOn( 0, NOTE_D + OCTAVE*5, 127 );
}

void loop()
{
  int i = CTV_CENTER14;   // middle of pitch bend range
  while( i < CTV_MAX14 )  // loop to upper bound of pitch bend range
  {
    synth.pitchBend( 0, i );
    i += 16;
    delay( 10 );
  }

  while( i > 0 )          // loop to lower bound of pitch bend range
  {
    synth.pitchBend( 0, i );
    i -= 64;
    delay( 16 );
  }
}
